package com.gap.historyemployee;

import com.buanalintas.bynga.Action;
import com.buanalintas.bynga.Dictionary;
import com.buanalintas.bynga.Field;
import com.buanalintas.bynga.Page;
import com.buanalintas.bynga.formatter.MoneyFormatter;
import com.gap.entities.GapMasterHistoryEmployee;

/**
 *
 * Class HistoryEmployee is ...
 *
 * Generated on Fri Jan 16 15:10:27 ICT 2015
 *
 * @version 1.0
 * @author Mr. Kazao™
 * @since Bynga 1.0
 *
 */
public class MasterHistoryEmployee extends Page {

    private Field historyId;
    private Field historyDate;
    private Field historyEmployeeName;
    private Field historyPlatform;
    private Field historyValue;
    private Field historyTimestamp;
    private Field historyUserId;
    private Field historyUnitId;
    private Field historyEmployeeId;

//    private static String MESSAGE_DAILY = "<!--MESSAGE-DAILY-->";
//    private static String MESSAGE_WEEKLY = "<!--MESSAGE-WEEKLY-->";
//    private static String MESSAGE_MONTHLY_YEAR = "<!--MESSAGE-MONTHLY-YEAR-->";
//    private static String MESSAGE_MONTHLY_MONTH = "<!--MESSAGE-MONTHLY-MONTH-->";
//    private static String MESSAGE_YEARLY = "<!--MESSAGE-YEARLY-->";
//    private static String MESSAGE_CUSTOM = "<!--MESSAGE-CUSTOM-->";
//    private static String SELECT_MODE = "<!--SELECT-MODE-->";
//    private static String SELECT_MODE_ONCHANGE = "<!--SELECT-MODE-ONCHANGE-->";
//    private static String SELECT_VALUES = "<!--SELECT-VALUES-->";
//    private static String SELECT_FILTER = "<!--SELECT-FILTER-->";
//    private static String SELECT_FILTER_VALUES = "<!--SELECT-FILTER-VALUES-->";
//    private static String MODE_DAILY = "MODE-DAILY";
//    private static String DAILY_SELECT_DATE = "<!--DAILY-SELECT-DATE-->";
//    private static String DAILY_DATE_VALUE = "<!--DAILY-DATE-VALUE-->";
//    private static String MODE_WEEKLY = "MODE-WEEKLY";
//    private static String WEEKLY_START_DATE_VALUE = "<!--WEEKLY-START-DATE-VALUE-->";
//    private static String WEEKLY_SELECT_START_DATE = "<!--WEEKLY-SELECT-START-DATE-->";
//    private static String MODE_MONTHLY = "MODE-MONTHLY";
//    private static String MONTHLY_SELECT_YEAR = "<!--MONTHLY-SELECT-YEAR-->";
//    private static String MONTHLY_SELECT_YEAR_VALUES = "<!--MONTHLY-SELECT-YEAR-VALUES-->";
//    private static String MONTHLY_SELECT_MONTH = "<!--MONTHLY-SELECT-MONTH-->";
//    private static String MONTHLY_SELECT_MONTH_VALUES = "<!--MONTHLY-SELECT-MONTH-VALUES-->";
//    private static String MODE_YEARLY = "MODE-YEARLY";
//    private static String YEARLY_SELECT_YEAR = "<!--YEARLY-SELECT-YEAR-->";
//    private static String YEARLY_SELECT_YEAR_VALUES = "<!--YEARLY-SELECT-YEAR-VALUES-->";
//    private static String MODE_CUSTOM = "MODE-CUSTOM";
//    private static String CUSTOM_SELECT_START_DATE = "<!--CUSTOM-SELECT-START-DATE-->";
//    private static String CUSTOM_START_DATE_VALUE = "<!--CUSTOM-START-DATE-VALUE-->";
//    private static String CUSTOM_SELECT_END_DATE = "<!--CUSTOM-SELECT-END-DATE-->";
//    private static String CUSTOM_END_DATE_VALUE = "<!--CUSTOM-END-DATE-VALUE-->";
//    private static String BUTTON_SEARCH = "<!--BUTTON-SEARCH-->";
//    private static String LIST_DATA = "<!--LIST-DATA-->";
//    private static String RECORD = "<!--RECORD-->";
//    private static String WARNING = "<!--WARNING-->";
//    private static String TOTAL = "TOTAL";
//    private static String TOTAL_CAPTION = "<!--TOTAL-CAPTION-->";
//    private static String TOTAL_TEXT = "<!--TOTAL-TEXT-->";
//    private static String RECAP_EXPORT_LINK = "<!--RECAP-EXPORT-LINK-->";
//    private static String RECAP_EXPORT = "RECAP-EXPORT";
//    private static String SELECT_EMPLOYEE = "<!--SELECT-EMPLOYEE-->";
//    private static String SELECT_EMPLOYEE_VALUES = "<!--SELECT-EMPLOYEE-VALUES-->";
//    private static String SELECT_UNIT = " <!--SELECT-UNIT-->";
//    private static String SELECT_UNIT_VALUES = " <!--SELECT-UNIT-VALUES-->";
//
//    private Action actionExport = new Action("export", "Export");
    public MasterHistoryEmployee() {
        super();

        setTheClass(GapMasterHistoryEmployee.class);

        historyId = new Field();
        historyId.setName("historyId");
        historyId.setCaption("id");
        //historyId.setInfo("history id");
        historyId.setListProperties(" align=\"left\" width=\"1%\" nowrap");
        historyId.setInputProperties(" size=\"20\"");
        getFields().add(historyId);

        historyDate = new Field();
        historyDate.setName("historyDate");
        historyDate.setCaption("date");
        //historyEmployeeName.setInfo("history employee name");
        historyDate.setListProperties(" align=\"center\" width=\"5%\" nowrap");
        historyDate.setInputProperties(" size=\"20\"");
        getFields().add(historyDate);

        historyEmployeeName = new Field();
        historyEmployeeName.setName("historyEmployeeName");
        historyEmployeeName.setCaption("name");
        //historyEmployeeName.setInfo("history employee name");
        historyEmployeeName.setListProperties(" align=\"left\" width=\"30%\" nowrap");
        historyEmployeeName.setInputProperties(" size=\"20\"");
        getFields().add(historyEmployeeName);

        historyPlatform = new Field();
        historyPlatform.setName("historyPlatform");
        historyPlatform.setCaption("platform");
        historyPlatform.setFormater(MoneyFormatter.getInstance());
        historyPlatform.setListProperties(" align=\"right\" width=\"15%\" nowrap");
        historyPlatform.setInputProperties(" size=\"20\"");
        getFields().add(historyPlatform);

        historyValue = new Field();
        historyValue.setName("historyValue");
        historyValue.setCaption("value");
        historyValue.setFormater(MoneyFormatter.getInstance());
        historyValue.setListProperties(" align=\"right\" width=\"15%\" nowrap");
        historyValue.setInputProperties(" size=\"20\"");
        getFields().add(historyValue);

        historyTimestamp = new Field();
        historyTimestamp.setName("historyTimestamp");
        historyTimestamp.setCaption("timestamp");
        //historyTimestamp.setInfo("history timestamp");
        historyTimestamp.setListProperties(" align=\"center\" width=\"0%\" nowrap");
        historyTimestamp.setInputProperties(" size=\"12\"");
        //historyTimestamp.setFormatter(DateFormatter.getInstanceDateTime(this));
        getFields().add(historyTimestamp);

//        historyDate = new Field();
//        historyDate.setName("historyDate");
//        historyDate.setCaption("date");
//        //historyDate.setInfo("history date");
//        historyDate.setListProperties(" align=\"center\" width=\"20%\" nowrap");
//        historyDate.setInputProperties(" size=\"8\"");
//        historyDate.setFormatter(DateFormatter.getInstanceDate(this));
//        getFields().add(historyDate);
        historyUserId = new Field();
        historyUserId.setName("historyUserId");
        historyUserId.setCaption("user");
        //historyUserId.setInfo("history user id");
        historyUserId.setListProperties(" align=\"center\" width=\"0%\" nowrap");
        historyUserId.setInputProperties(" size=\"20\"");
        getFields().add(historyUserId);

        historyUnitId = new Field();
        historyUnitId.setName("historyUnitId");
        historyUnitId.setCaption("unit");
        //historyUnitId.setInfo("history unit id");
        historyUnitId.setListProperties(" align=\"center\" width=\"20%\" nowrap");
        historyUnitId.setInputProperties(" size=\"20\"");
        getFields().add(historyUnitId);

        historyEmployeeId = new Field();
        historyEmployeeId.setName("historyEmployeeId");
        historyEmployeeId.setCaption("employee id");
        //historyEmployeeId.setInfo("history employee id");
        historyEmployeeId.setListProperties(" align=\"center\" width=\"15%\" nowrap");
        historyEmployeeId.setInputProperties(" size=\"20\"");
        getFields().add(historyEmployeeId);

        getActions().remove(Action.ADD);
        getActions().remove(Action.DELETE);
        getActions().remove(Action.DELETE_MULTI);
        getActions().remove(Action.EDIT);

        fillFields();
        getFieldsList().clear();
//        getFieldsList().add(historyUserId);
        getFieldsList().add(historyUnitId);
        getFieldsList().add(historyDate);
        getFieldsList().add(historyEmployeeId);
        getFieldsList().add(historyEmployeeName);
        getFieldsList().add(historyPlatform);
        getFieldsList().add(historyValue);
//        getFieldsList().add(historyTimestamp);
//        getActions().add(actionExport);

        getFieldsView().clear();
        getFieldsView().add(historyUnitId);
        getFieldsView().add(historyDate);
        getFieldsView().add(historyEmployeeId);
        getFieldsView().add(historyEmployeeName);
        getFieldsView().add(historyPlatform);
        getFieldsView().add(historyValue);
        
        getFieldsPrint().clear();
        getFieldsPrint().add(historyUnitId);
        getFieldsPrint().add(historyDate);
        getFieldsPrint().add(historyEmployeeId);
        getFieldsPrint().add(historyEmployeeName);
        getFieldsPrint().add(historyPlatform);
        getFieldsPrint().add(historyValue);


        setExportList(getClass().getResourceAsStream("HisEmployeeList.jasper"));
        setExport(getClass().getResourceAsStream("HisEmployee.jasper"));
    }

    @Override
    public void beforeExport() {
        getExportParams().put("title", Dictionary.getValue(this, "History Employee"));
    }

    @Override
    public void beforeExportMulti() {
        beforeExport();
    }
//    @Override
//    public boolean isSearchVisible() {
//        return false;
//    }
//
//    @Override
//    public boolean isTitleVisible() {
//        return false;
//    }
//
//    @Override
//    public StringBuilder process() {
//        if (getAction().equals(actionExport)) {
//            try {
//                updateExportParams();
//                if ("2".equals(getCurrentUser().getUserExport())) {
//                    getResponse().setHeader("Content-Type", "application/vnd.ms-excel ");
//                } else {
//                    getResponse().setHeader("Content-Type", "application/pdf");
//                }
//                JRDataSource datasource = null;
//                EntityManager em = getController().getEntityManager();
//
//                String mode = getRequest().getParameter("mode");
//
//                MasterUnit unit = null;
//                String filterUnit = Utility.getParameterEmpty(getRequest(), "unit");
//                System.out.println("UNIT-->" + filterUnit);
//                try {
//                    unit = (MasterUnit) getEntityManager().createQuery("SELECT t FROM MasterUnit t WHERE t.unitName='" + filterUnit + "' ").setHint(Persistence.REFRESH_HINT, true).getSingleResult();
//                    getExportParams().put("unit", Utility.getParameterEmpty(getRequest(), "unit") + " - " + unit.getUnitName());
//                } catch (Exception e) {
//                    getExportParams().put("unit", Utility.getParameterEmpty(getRequest(), "unit"));
//                }
//
//                GapMasterEmployee employee = null;
//                String filterEmployee = Utility.getParameterEmpty(getRequest(), "employee");
//                System.out.println("EMP-->" + filterEmployee);
//                try {
//                    employee = (GapMasterEmployee) getEntityManager().createQuery("SELECT t FROM GapMasterEmployee t WHERE t.employeeNameFirst='" + filterEmployee + "' ").setHint(Persistence.REFRESH_HINT, true).getSingleResult();
//                    getExportParams().put("employee", Utility.getParameterEmpty(getRequest(), "employee") + " - " + employee.getEmployeeNameFirst());
//                } catch (Exception e) {
//                    getExportParams().put("employee", Utility.getParameterEmpty(getRequest(), "employee"));
//                }
//
//                if ("1".equals(mode)) {
//                    String filterDate = Utility.getParameterEmpty(getRequest(), "recapDate");
//                    getExportParams().put("filter", Dictionary.getValue(this, "From") + " " + Utility.getPostParameterEmpty(this, "recapDate"));
//                    getExportParams().put("title", Dictionary.getValue(this, "History Employee") + " #" + Dictionary.getValue(this, "Daily"));
//                    getExportParams().put("unit", Utility.getParameterEmpty(getRequest(), "unit"));
//                    getExportParams().put("employee", Utility.getParameterEmpty(getRequest(), "employee"));
//                    if (!"".equals(filterDate)) {
//                        getExportParams().put("filter", Dictionary.getValue(this, "Date") + " " + Utility.getPostParameterEmpty(this, "recapDate"));
//                        DateFormatter dateTimeFormatter = DateFormatter.getInstanceDateTime(this);
//                        if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit")) && "*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterDate + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(filterDate + " 23:59:59"));
//
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit"))) {
//                            getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + filterEmployee + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterDate + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(filterDate + " 23:59:59"));
//
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyUnitId.unitName='" + filterUnit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterDate + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(filterDate + " 23:59:59"));
//                        } else {
//                            getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + filterEmployee + "' AND t.historyUnitId.unitName='" + filterUnit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterDate + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(filterDate + " 23:59:59"));
//                        }
//                        getController().setPaginationFilter("&mode=" + mode + "&unit=" + filterUnit + "&employee=" + filterEmployee + "&recapDate=" + filterDate);
//                    }
//
//                } else if ("2".equals(mode)) {
//                    String filterStartDate = Utility.getParameterEmpty(getRequest(), "startDate");
//                    if (!"".equals(filterStartDate)) {
//                        getExportParams().put("filter", Dictionary.getValue(this, "From") + " " + Utility.getPostParameterEmpty(this, "startDate"));
//                        getExportParams().put("title", Dictionary.getValue(this, "History Employee") + " #" + Dictionary.getValue(this, "Weekly"));
//                        getExportParams().put("unit", Utility.getParameterEmpty(getRequest(), "unit"));
//                        getExportParams().put("employee", Utility.getParameterEmpty(getRequest(), "employee"));
//                        DateFormatter dateFormatter = DateFormatter.getInstanceDate(this);
//                        Calendar cal = Calendar.getInstance();
//                        cal.setTime((Date) dateFormatter.parse(filterStartDate));
//                        String start = dateFormatter.format(cal.getTime());
//                        cal.add(Calendar.DATE, 7);
//                        String end = dateFormatter.format(cal.getTime());
//                        DateFormatter dateTimeFormatter = DateFormatter.getInstanceDateTime(this);
//                        if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit")) && "*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit"))) {
//                            getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + filterEmployee + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyUnitId.unitName='" + filterUnit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//
//                        } else {
//                            getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + filterEmployee + "' AND t.historyUnitId.unitName='" + filterUnit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//                        }
//
//                        getController().setPaginationFilter("&mode=" + mode + "&unit=" + filterUnit + "&employee=" + filterEmployee + "&startDate=" + filterStartDate);
//                    }
//
//                } else if ("3".equals(mode)) {
//                    String filterYear = Utility.getParameterEmpty(getRequest(), "recapYear");
//                    String filterMonth = Utility.getParameterEmpty(getRequest(), "recapMonth");
//                    if (!"".equals(filterYear) && !"".equals(filterMonth)) {
//                        getExportParams().put("filter", Utility.getPostParameterEmpty(this, "recapYear") + " - " + Dictionary.getValue(this, Utility.getLongMonthName(Integer.parseInt(Utility.getPostParameterEmpty(this, "recapMonth")))));
//                        getExportParams().put("title", Dictionary.getValue(this, "History Payment") + " #" + Dictionary.getValue(this, "Monthly"));
//                        getExportParams().put("unit", Utility.getParameterEmpty(getRequest(), "unit"));
//                        DateFormatter dateFormatter = DateFormatter.getInstanceDate(this);
//                        StringBuilder date = new StringBuilder(dateFormatter.getFormat());
//                        Utility.replaceAll(date, "yyyy", filterYear);
//                        Utility.replaceAll(date, "MM", filterMonth);
//                        Utility.replaceAll(date, "dd", "01");
//                        String start = date.toString();
//                        Calendar cal = Calendar.getInstance();
//                        cal.setTime((Date) dateFormatter.parse(start));
//                        int max = cal.getActualMaximum(Calendar.DATE);
//                        date = new StringBuilder(dateFormatter.getFormat());
//                        Utility.replaceAll(date, "yyyy", filterYear);
//                        Utility.replaceAll(date, "MM", filterMonth);
//                        Utility.replaceAll(date, "dd", "" + max);
//                        String end = date.toString();
//                        DateFormatter dateTimeFormatter = DateFormatter.getInstanceDateTime(this);
//                        if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit")) && "*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit"))) {
//                            getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + filterEmployee + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyUnitId.unitName='" + filterUnit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//                        } else {
//                            getController().setWhere("t.historyUnitId.unitName='" + filterUnit + "' AND t.historyEmployeeId.employeeName='" + filterEmployee + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//                        }
//
//                        getController().setPaginationFilter("&mode=" + mode + "&unit=" + filterUnit + "&employee=" + filterEmployee + "&recapYear=" + filterYear + "&filterMonth=" + filterMonth);
//                    }
//
//                } else if ("4".equals(mode)) {
//                    String filterYear = Utility.getParameterEmpty(getRequest(), "recapYear");
//                    if (!"".equals(filterYear)) {
//
//                        getExportParams().put("filter", Dictionary.getValue(this, "Year") + " " + Utility.getPostParameterEmpty(this, "recapYear"));
//                        getExportParams().put("title", Dictionary.getValue(this, "History Payment") + " #" + Dictionary.getValue(this, "Yearly"));
//                        DateFormatter dateFormatter = DateFormatter.getInstanceDate(this);
//                        StringBuilder date = new StringBuilder(dateFormatter.getFormat());
//                        Utility.replaceAll(date, "yyyy", filterYear);
//                        Utility.replaceAll(date, "MM", "01");
//                        Utility.replaceAll(date, "dd", "01");
//                        String start = date.toString();
//                        date = new StringBuilder(dateFormatter.getFormat());
//                        Utility.replaceAll(date, "yyyy", filterYear);
//                        Utility.replaceAll(date, "MM", "12");
//                        Utility.replaceAll(date, "dd", "31");
//                        String end = date.toString();
//                        DateFormatter dateTimeFormatter = DateFormatter.getInstanceDateTime(this);
//                        if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit")) && "*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit"))) {
//                            getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + filterEmployee + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyUnitId.unitName='" + filterUnit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//
//                        } else {
//                            getController().setWhere("t.historyUnitId.unitName='" + filterUnit + "' AND t.historyEmployeeId.employeeNameFirst='" + filterEmployee + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//                        }
//
//                        getController().setPaginationFilter("&mode=" + mode + "&unit=" + filterUnit + "&employee=" + filterEmployee + "&recapYear=" + filterYear);
//
//                    }
//
//                } else if ("5".equals(mode)) {
//                    String filterStartDate = Utility.getParameterEmpty(getRequest(), "startDate");
//                    String filterEndDate = Utility.getParameterEmpty(getRequest(), "endDate");
//                    getExportParams().put("title", Dictionary.getValue(this, "History Employee") + " #" + Dictionary.getValue(this, "Custom"));
//                    if (!"".equals(filterStartDate) && "".equals(filterEndDate)) {
//                        getExportParams().put("filter", Dictionary.getValue(this, "From") + " " + Utility.getPostParameterEmpty(this, "startDate"));
//                        getExportParams().put("unit", Utility.getParameterEmpty(getRequest(), "unit"));
//                        DateFormatter dateTimeFormatter = DateFormatter.getInstanceDateTime(this);
//                        if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit")) && "*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyTimestamp >= :start");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit"))) {
//                            getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + filterEmployee + "' AND t.historyTimestamp >= :start");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyUnitId.unitName='" + filterUnit + "' AND t.historyTimestamp >= :start");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                        } else {
//                            getController().setWhere("t.historyUnitId.unitName='" + filterUnit + "' AND t.historyEmployeeId.employeeNameFirst='" + filterEmployee + "' AND t.historyTimestamp >= :start");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                        }
//                    } else if ("".equals(filterStartDate) && !"".equals(filterEndDate)) {
//                        getExportParams().put("filter", Dictionary.getValue(this, "To") + " " + Utility.getPostParameterEmpty(this, "endDate"));
//                        getExportParams().put("unit", Utility.getParameterEmpty(getRequest(), "unit"));
//                        DateFormatter dateTimeFormatter = DateFormatter.getInstanceDateTime(this);
//                        if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit")) && "*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyTimestamp <= :end");
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit"))) {
//                            getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + filterEmployee + "' AND t.historyTimestamp <= :end");
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyUnitId.unitName='" + filterUnit + "' AND t.historyTimestamp <= :end");
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        } else {
//                            getController().setWhere("t.historyUnitId.unitName='" + filterUnit + "' AND t.historyEmployeeId.employeeName='" + filterEmployee + "' AND t.historyTimestamp <= :end");
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        }
//
//                    } else if (!"".equals(filterStartDate) && !"".equals(filterEndDate)) {
//                        getExportParams().put("filter", Dictionary.getValue(this, "From") + " " + Utility.getPostParameterEmpty(this, "startDate") + " " + Dictionary.getValue(this, "to") + " " + Utility.getPostParameterEmpty(this, "endDate"));
//                        getExportParams().put("unit", Utility.getParameterEmpty(getRequest(), "unit"));
//                        DateFormatter dateTimeFormatter = DateFormatter.getInstanceDateTime(this);
//                        if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit")) && "*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit"))) {
//                            getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + filterEmployee + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyUnitId.unitName='" + filterUnit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        } else {
//                            getController().setWhere("t.historyUnitId.unitName='" + filterUnit + "' AND t.historyEmployeeId.employeeNameFirst='" + filterEmployee + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        }
//                    }
//                }
//
//                datasource = new JRBeanArrayDataSource(getController().getData(true).toArray());
//                JasperPrint jasperPrint = JasperFillManager.fillReport(getClass().getResourceAsStream("MasHisEmployeeList.jasper"), getExportParams(), datasource);
//                if ("2".equals(getCurrentUser().getUserExport())) {
//                    JRXlsExporter excelExporter = new JRXlsExporter();
//                    excelExporter.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint);
//                    excelExporter.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, getResponse().getOutputStream());
//                    excelExporter.exportReport();
//                } else {
//                    JasperExportManager.exportReportToPdfStream(jasperPrint, getResponse().getOutputStream());
//                }
//                return null;
//            } catch (Exception e) {
//                Logger.getInstance().log(e);
//            }
//            return new StringBuilder();
//        } else {
//            StringBuilder content = Utility.load(Configuration.getThemePackage() + "content.html");
//            Template template = new Template();
//            template.loadTemplate("/com/gap/historyemployee/recap.html");
//
//            template.addValue(MESSAGE_DAILY, Dictionary.getValue(this, "Please enter date"));
//            template.addValue(MESSAGE_WEEKLY, Dictionary.getValue(this, "Please enter start date"));
//            template.addValue(MESSAGE_MONTHLY_YEAR, Dictionary.getValue(this, "Please select year"));
//            template.addValue(MESSAGE_MONTHLY_MONTH, Dictionary.getValue(this, "Please select month"));
//            template.addValue(MESSAGE_YEARLY, Dictionary.getValue(this, "Please select year"));
//            template.addValue(MESSAGE_CUSTOM, Dictionary.getValue(this, "Please enter start date or end date or both"));
//
//            EntityManager em = getEntityManager();
//
//            template.addValue(SELECT_EMPLOYEE, Dictionary.getValue(this, "Select Employee"));
//            String selectEmployee = "<option value=\"*\">" + Dictionary.getValue(this, "All Employee") + "</option>";
//            String employee = Utility.getParameterEmpty(getRequest(), "employee");
//            try {
//                List<GapMasterEmployee> employees = getEntityManager().createQuery("SELECT t FROM GapMasterEmployee t ORDER BY t.employeeNameFirst").setHint(Persistence.REFRESH_HINT, true).getResultList();
//                for (GapMasterEmployee emp : employees) {
//                    selectEmployee += "<option value=\"" + emp.getEmployeeNameFirst() + "\"" +
//                            (emp.getEmployeeNameFirst().equals(employee) ? " selected" : "") + ">" +
//                           emp.getEmployeeNumber() +" - "+ emp.getEmployeeNameFirst() +  "</option>";
//                }
//            } catch (Exception e) {
//            }
//            template.addValue(SELECT_EMPLOYEE_VALUES, selectEmployee);
////--------------------
//            template.addValue(SELECT_UNIT, Dictionary.getValue(this, "Select Unit"));
//            String selectUnit = "<option value=\"*\">" + Dictionary.getValue(this, "All Unit") + "</option>";
//            String unit = Utility.getParameterEmpty(getRequest(), "unit");
//            try {
//                List<MasterUnit> units = getEntityManager().createQuery("SELECT t FROM MasterUnit t ORDER BY t.unitName").setHint(Persistence.REFRESH_HINT, true).getResultList();
//                for (MasterUnit unt : units) {
//                    selectUnit += "<option value=\"" + unt.getUnitName() + "\"" + (unt.getUnitName().equals(unit) ? " selected" : "") + ">" + unt.getUnitName() + "</option>";
//                }
//            } catch (Exception e) {
//            }
//            template.addValue(SELECT_UNIT_VALUES, selectUnit);
////----------------------------------------
//            System.out.println("UNITTTTTT-->" + unit);
//            System.out.println("EMPLOYYYY-->" + employee);
//            
//            template.addValue(SELECT_MODE, Dictionary.getValue(this, "Select mode"));
//            template.addValue(SELECT_MODE_ONCHANGE, Dictionary.getValue(this, "'?m=" + getMenu().getMenuName() + "&a=" + getMenu().getMenuAction() + "&mode='+this.value"));
//
//            String selectMode = "";
//            String mode = Utility.getParameterEmpty(getRequest(), "mode");
//            if ("".equals(mode)) {
//                mode = "1";
//            }
//            selectMode += "<option value=\"1\"" + ("1".equals(mode) ? " selected" : "") + ">" + Dictionary.getValue(this, "Daily") + "</option>";
//            selectMode += "<option value=\"2\"" + ("2".equals(mode) ? " selected" : "") + ">" + Dictionary.getValue(this, "Weekly") + "</option>";
//            selectMode += "<option value=\"3\"" + ("3".equals(mode) ? " selected" : "") + ">" + Dictionary.getValue(this, "Monthly") + "</option>";
//            selectMode += "<option value=\"4\"" + ("4".equals(mode) ? " selected" : "") + ">" + Dictionary.getValue(this, "Yearly") + "</option>";
//            selectMode += "<option value=\"5\"" + ("5".equals(mode) ? " selected" : "") + ">" + Dictionary.getValue(this, "Custom") + "</option>";
//            template.addValue(SELECT_VALUES, selectMode);
//
//            boolean complete = false;
//            if ("1".equals(mode)) {
//                StringBuilder parameter = template.getEmptyElement(MODE_DAILY);
//                Utility.replaceAll(parameter, DAILY_SELECT_DATE, Dictionary.getValue(this, "Date"));
//                Utility.replaceAll(parameter, DAILY_DATE_VALUE, Utility.getParameterEmpty(getRequest(), "recapDate"));
//                template.addElement(MODE_DAILY, parameter);
//                template.addElement(MODE_WEEKLY, null);
//                template.addElement(MODE_MONTHLY, null);
//                template.addElement(MODE_YEARLY, null);
//                template.addElement(MODE_CUSTOM, null);
//                String filterDate = Utility.getParameterEmpty(getRequest(), "recapDate");
//                if (!"".equals(filterDate)) {
//                    StringBuilder export = template.getEmptyElement(RECAP_EXPORT);
//                    Utility.replaceAll(export, RECAP_EXPORT_LINK, "?m=" + getMenu().getMenuName() + "&a=" + actionExport.getName() + "&mode=" + Utility.getPostParameterEmpty(this, "mode") + "&unit=" + Utility.getPostParameterEmpty(this, "unit") + "&employee=" + Utility.getPostParameterEmpty(this, "employee") + "&recapDate=" + Utility.getPostParameterEmpty(this, "recapDate"));
//                    template.addElement(RECAP_EXPORT, export);
//                    DateFormatter dateTimeFormatter = DateFormatter.getInstanceDateTime(this);
//                    if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit")) && "*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                        getController().setWhere("t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(filterDate + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(filterDate + " 23:59:59"));
//
//                    } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit"))) {
//                        getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + employee + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(filterDate + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(filterDate + " 23:59:59"));
//
//                    } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                        getController().setWhere("t.historyUnitId.unitName='" + unit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(filterDate + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(filterDate + " 23:59:59"));
//                    } else {
//                        getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + employee + "' AND t.historyUnitId.unitName='" + unit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(filterDate + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(filterDate + " 23:59:59"));
//                    }
//                    getController().setPaginationFilter("&mode=" + mode + "&unit=" + unit + "&employee=" + employee + "&recapDate=" + filterDate);
//                    complete = true;
//                } else {
//                    template.addValue(template.getEmptyElement(RECAP_EXPORT).toString(), null);
//                }
//
//            } else if ("2".equals(mode)) {
//                template.addElement(MODE_DAILY, null);
//                StringBuilder parameter = template.getEmptyElement(MODE_WEEKLY);
//                Utility.replaceAll(parameter, WEEKLY_SELECT_START_DATE, Dictionary.getValue(this, "Start date"));
//                Utility.replaceAll(parameter, WEEKLY_START_DATE_VALUE, Utility.getParameterEmpty(getRequest(), "startDate"));
//                template.addElement(MODE_WEEKLY, parameter);
//                template.addElement(MODE_MONTHLY, null);
//                template.addElement(MODE_YEARLY, null);
//                template.addElement(MODE_CUSTOM, null);
//                String filterStartDate = Utility.getParameterEmpty(getRequest(), "startDate");
//                if (!"".equals(filterStartDate)) {
//                    StringBuilder export = template.getEmptyElement(RECAP_EXPORT);
//                    Utility.replaceAll(export, RECAP_EXPORT_LINK, "?m=" + getMenu().getMenuName() + "&a=" + actionExport.getName() + "&mode=" + Utility.getPostParameterEmpty(this, "mode") + "&filter=" + Utility.getPostParameterEmpty(this, "filter") + "&startDate=" + Utility.getParameterEmpty(getRequest(), "startDate"));
//                    template.addElement(RECAP_EXPORT, export);
//
//                    DateFormatter dateFormatter = DateFormatter.getInstanceDate(this);
//                    Calendar cal = Calendar.getInstance();
//                    cal.setTime((Date) dateFormatter.parse(filterStartDate));
//                    String start = dateFormatter.format(cal.getTime());
//                    cal.add(Calendar.DATE, 7);
//                    String end = dateFormatter.format(cal.getTime());
//                    DateFormatter dateTimeFormatter = DateFormatter.getInstanceDateTime(this);
//                    if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit")) && "*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                        getController().setWhere("t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//
//                    } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit"))) {
//                        getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + employee + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//
//                    } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                        getController().setWhere("t.historyUnitId.unitName='" + unit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//                    } else {
//                        getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + employee + "' AND t.historyUnitId.unitName='" + unit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//                    }
//                    getController().setPaginationFilter("&mode=" + mode + "&unit=" + unit + "&employee=" + employee + "&startDate=" + filterStartDate);
//                    complete = true;
//                } else {
//                    template.addValue(template.getEmptyElement(RECAP_EXPORT).toString(), null);
//                }
//            } else if ("3".equals(mode)) {
//                template.addElement(MODE_DAILY, null);
//                template.addElement(MODE_WEEKLY, null);
//                StringBuilder parameter = template.getEmptyElement(MODE_MONTHLY);
//                Utility.replaceAll(parameter, MONTHLY_SELECT_YEAR, Dictionary.getValue(this, "Year"));
//                String selectYear = "<option value=\"\">" + Dictionary.getValue(this, "Select year") + "</option>";
//                int year = Calendar.getInstance().get(Calendar.YEAR);
//                for (int i = year; i >= 2010; i--) {
//                    selectYear += "<option value=\"" + i + "\"" + (("" + i).equals(Utility.getParameterEmpty(getRequest(), "recapYear")) ? " selected" : "") + ">" + i + "</option>";
//                }
//                Utility.replaceAll(parameter, MONTHLY_SELECT_YEAR_VALUES, selectYear);
//                Utility.replaceAll(parameter, MONTHLY_SELECT_MONTH, Dictionary.getValue(this, "Month"));
//                String selectMonth = "<option value=\"\">" + Dictionary.getValue(this, "Select month") + "</option>";
//                for (int i = 1; i <= 12; i++) {
//                    selectMonth += "<option value=\"" + i + "\"" + (("" + i).equals(Utility.getParameterEmpty(getRequest(), "recapMonth")) ? " selected" : "") + ">" + Dictionary.getValue(this, Utility.getLongMonthName(i)) + "</option>";
//                }
//                Utility.replaceAll(parameter, MONTHLY_SELECT_MONTH_VALUES, selectMonth);
//                template.addElement(MODE_MONTHLY, parameter);
//                template.addElement(MODE_YEARLY, null);
//                template.addElement(MODE_CUSTOM, null);
//                String filterYear = Utility.getParameterEmpty(getRequest(), "recapYear");
//                String filterMonth = Utility.getParameterEmpty(getRequest(), "recapMonth");
//                if (!"".equals(filterYear) && !"".equals(filterMonth)) {
//                    StringBuilder export = template.getEmptyElement(RECAP_EXPORT);
//                    Utility.replaceAll(export, RECAP_EXPORT_LINK, "?m=" + getMenu().getMenuName() + "&a=" + actionExport.getName() + "&mode=" + Utility.getPostParameterEmpty(this, "mode") + "&filter=" + Utility.getPostParameterEmpty(this, "filter") + "&recapYear=" + Utility.getPostParameterEmpty(this, "recapYear") + "&recapMonth=" + Utility.getPostParameterEmpty(this, "recapMonth"));
//                    template.addElement(RECAP_EXPORT, export);
//
//                    DateFormatter dateFormatter = DateFormatter.getInstanceDate(this);
//                    StringBuilder date = new StringBuilder(dateFormatter.getFormat());
//                    Utility.replaceAll(date, "yyyy", filterYear);
//                    Utility.replaceAll(date, "MM", filterMonth);
//                    Utility.replaceAll(date, "dd", "01");
//                    String start = date.toString();
//                    Calendar cal = Calendar.getInstance();
//                    cal.setTime((Date) dateFormatter.parse(start));
//                    int max = cal.getActualMaximum(Calendar.DATE);
//                    date = new StringBuilder(dateFormatter.getFormat());
//                    Utility.replaceAll(date, "yyyy", filterYear);
//                    Utility.replaceAll(date, "MM", filterMonth);
//                    Utility.replaceAll(date, "dd", "" + max);
//                    String end = date.toString();
//                    DateFormatter dateTimeFormatter = DateFormatter.getInstanceDateTime(this);
//                     if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit")) && "*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                        getController().setWhere("t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//
//                    } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit"))) {
//                        getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + employee + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//
//                    } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                        getController().setWhere("t.historyUnitId.unitName='" + unit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//                    } else {
//                        getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + employee + "' AND t.historyUnitId.unitName='" + unit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//                    }
//                    getController().setPaginationFilter("&mode=" + mode + "&unit=" + unit + "&employee=" + employee + "&recapYear=" + filterYear + "&filterMonth=" + filterMonth);
//                    complete = true;
//                } else {
//                    template.addValue(template.getEmptyElement(RECAP_EXPORT).toString(), null);
//                }
//            } else if ("4".equals(mode)) {
//                template.addElement(MODE_DAILY, null);
//                template.addElement(MODE_WEEKLY, null);
//                template.addElement(MODE_MONTHLY, null);
//                StringBuilder parameter = template.getEmptyElement(MODE_YEARLY);
//                Utility.replaceAll(parameter, YEARLY_SELECT_YEAR, Dictionary.getValue(this, "Year"));
//                String selectYear = "<option value=\"\">" + Dictionary.getValue(this, "Select year") + "</option>";
//                int year = Calendar.getInstance().get(Calendar.YEAR);
//                for (int i = year; i >= 2010; i--) {
//                    selectYear += "<option value=\"" + i + "\"" + (("" + i).equals(Utility.getParameterEmpty(getRequest(), "recapYear")) ? " selected" : "") + ">" + i + "</option>";
//                }
//                Utility.replaceAll(parameter, YEARLY_SELECT_YEAR_VALUES, selectYear);
//                template.addElement(MODE_YEARLY, parameter);
//                template.addElement(MODE_CUSTOM, null);
//                String filterYear = Utility.getParameterEmpty(getRequest(), "recapYear");
//                if (!"".equals(filterYear)) {
//                    StringBuilder export = template.getEmptyElement(RECAP_EXPORT);
//                    Utility.replaceAll(export, RECAP_EXPORT_LINK, "?m=" + getMenu().getMenuName() + "&a=" + actionExport.getName() + "&mode=" + Utility.getPostParameterEmpty(this, "mode") + "&filter=" + Utility.getPostParameterEmpty(this, "filter") + "&recapYear=" + Utility.getPostParameterEmpty(this, "recapYear"));
//                    template.addElement(RECAP_EXPORT, export);
//
//                    DateFormatter dateFormatter = DateFormatter.getInstanceDate(this);
//                    StringBuilder date = new StringBuilder(dateFormatter.getFormat());
//                    Utility.replaceAll(date, "yyyy", filterYear);
//                    Utility.replaceAll(date, "MM", "01");
//                    Utility.replaceAll(date, "dd", "01");
//                    String start = date.toString();
//                    date = new StringBuilder(dateFormatter.getFormat());
//                    Utility.replaceAll(date, "yyyy", filterYear);
//                    Utility.replaceAll(date, "MM", "12");
//                    Utility.replaceAll(date, "dd", "31");
//                    String end = date.toString();
//                    DateFormatter dateTimeFormatter = DateFormatter.getInstanceDateTime(this);
//                     if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit")) && "*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                        getController().setWhere("t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//
//                    } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit"))) {
//                        getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + employee + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//
//                    } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                        getController().setWhere("t.historyUnitId.unitName='" + unit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//                    } else {
//                        getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + employee + "' AND t.historyUnitId.unitName='" + unit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                        getController().addParameter("start", dateTimeFormatter.parse(start + " 00:00:00"));
//                        getController().addParameter("end", dateTimeFormatter.parse(end + " 23:59:59"));
//                    }
//                    getController().setPaginationFilter("&mode=" + mode + "&unit=" + unit + "&employee=" + employee + "&recapYear=" + filterYear);
//                    complete = true;
//                } else {
//                    template.addValue(template.getEmptyElement(RECAP_EXPORT).toString(), null);
//                }
//            } else if ("5".equals(mode)) {
//                template.addElement(MODE_DAILY, null);
//                template.addElement(MODE_WEEKLY, null);
//                template.addElement(MODE_MONTHLY, null);
//                template.addElement(MODE_YEARLY, null);
//                String filterStartDate = Utility.getParameterEmpty(getRequest(), "startDate");
//                String filterEndDate = Utility.getParameterEmpty(getRequest(), "endDate");
//                if (!"".equals(filterStartDate) && "".equals(filterEndDate)) {
//                    StringBuilder export = template.getEmptyElement(RECAP_EXPORT);
//                    Utility.replaceAll(export, RECAP_EXPORT_LINK, "?m=" + getMenu().getMenuName() + "&a=" + actionExport.getName() + "&mode=" + Utility.getPostParameterEmpty(this, "mode") + "&filter=" + Utility.getPostParameterEmpty(this, "filter") + "&startDate=" + Utility.getPostParameterEmpty(this, "startDate") + "&endDate=" + Utility.getPostParameterEmpty(this, "endDate"));
//                    template.addElement(RECAP_EXPORT, export);
//
//                    DateFormatter dateTimeFormatter = DateFormatter.getInstanceDateTime(this);
//                     if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit")) && "*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyTimestamp >= :start");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit"))) {
//                            getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + employee + "' AND t.historyTimestamp >= :start");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyUnitId.unitName='" + unit + "' AND t.historyTimestamp >= :start");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                        } else {
//                            getController().setWhere("t.historyUnitId.unitName='" + unit + "' AND t.historyEmployeeId.employeeNameFirst='" + employee + "' AND t.historyTimestamp >= :start");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                        }
//                    complete = true;
//                } else if ("".equals(filterStartDate) && !"".equals(filterEndDate)) {
//                    StringBuilder export = template.getEmptyElement(RECAP_EXPORT);
//                    Utility.replaceAll(export, RECAP_EXPORT_LINK, "?m=" + getMenu().getMenuName() + "&a=" + actionExport.getName() + "&mode=" + Utility.getPostParameterEmpty(this, "mode") + "&filter=" + Utility.getPostParameterEmpty(this, "filter") + "&endDate=" + Utility.getPostParameterEmpty(this, "endDate"));
//                    template.addElement(RECAP_EXPORT, export);
//                    DateFormatter dateTimeFormatter = DateFormatter.getInstanceDateTime(this);
//                  if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit")) && "*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyTimestamp <= :end");
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit"))) {
//                            getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + employee + "' AND t.historyTimestamp <= :end");
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyUnitId.unitName='" + unit + "' AND t.historyTimestamp <= :end");
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        } else {
//                            getController().setWhere("t.historyUnitId.unitName='" + unit + "' AND t.historyEmployeeId.employeeNameFirst='" + employee + "' AND  t.historyTimestamp <= :end");
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        }
//                    complete = true;
//                } else if (!"".equals(filterStartDate) && !"".equals(filterEndDate)) {
//                    StringBuilder export = template.getEmptyElement(RECAP_EXPORT);
//                    Utility.replaceAll(export, RECAP_EXPORT_LINK, "?m=" + getMenu().getMenuName() + "&a=" + actionExport.getName() + "&mode=" + Utility.getPostParameterEmpty(this, "mode") + "&filter=" + Utility.getPostParameterEmpty(this, "filter") + "&startDate=" + Utility.getPostParameterEmpty(this, "startDate") + "&endDate=" + Utility.getPostParameterEmpty(this, "endDate"));
//                    template.addElement(RECAP_EXPORT, export);
//                    DateFormatter dateTimeFormatter = DateFormatter.getInstanceDateTime(this);
//                      if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit")) && "*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "unit"))) {
//                            getController().setWhere("t.historyEmployeeId.employeeNameFirst='" + employee + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        } else if ("*".equals(Utility.getParameterEmpty(getRequest(), "employee"))) {
//                            getController().setWhere("t.historyUnitId.unitName='" + unit + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        } else {
//                            getController().setWhere("t.historyUnitId.unitName='" + unit + "' AND t.historyEmployeeId.employeeNameFirst='" + employee + "' AND t.historyTimestamp BETWEEN :start AND :end");
//                            getController().addParameter("start", dateTimeFormatter.parse(filterStartDate + " 00:00:00"));
//                            getController().addParameter("end", dateTimeFormatter.parse(filterEndDate + " 23:59:59"));
//                        }
//                    
//                    complete = true;
//                } else {
//                    template.addValue(template.getEmptyElement(RECAP_EXPORT).toString(), null);
//                }
//                getController().setPaginationFilter("&mode=" + mode + "&unit=" + unit + "&startDate=" + filterStartDate + "&endDate=" + filterEndDate);
//                StringBuilder parameter = template.getEmptyElement(MODE_CUSTOM);
//                Utility.replaceAll(parameter, CUSTOM_SELECT_START_DATE, Dictionary.getValue(this, "Start date"));
//                Utility.replaceAll(parameter, CUSTOM_START_DATE_VALUE, Utility.getParameterEmpty(getRequest(), "startDate"));
//                Utility.replaceAll(parameter, CUSTOM_SELECT_END_DATE, Dictionary.getValue(this, "End date"));
//                Utility.replaceAll(parameter, CUSTOM_END_DATE_VALUE, Utility.getParameterEmpty(getRequest(), "endDate"));
//                template.addElement(MODE_CUSTOM, parameter);
//            }
//            template.addValue(BUTTON_SEARCH, Dictionary.getValue(this, "Search"));
//            int record = getController().getRecordCount();
//            template.addValue(RECORD, Dictionary.getValue(this, "Total all record") + ": " + NumberFormatter.getInstance().format(record));
//            if (record > 10000000) {
//                template.addValue(WARNING, "return confirm('" + Dictionary.getValue(this, "Records is to big need long time to process, approximately") + " " + NumberFormatter.getInstance().format(record) + " " + Dictionary.getValue(this, "records, are you sure want to continue?") + "');");
//            } else {
//                template.addValue(WARNING, "");
//            }
//            if (complete) {
//                template.addValue(LIST_DATA, PageList.process(this).toString());
////                try {
////                    Object down = getController().getStatistic("SUM(t.depositPaymentValue)");
////                    StringBuilder total = template.getEmptyElement(TOTAL);
////                    Utility.replaceAll(total, TOTAL_CAPTION, Dictionary.getValue(this, "Total value"));
////                    Utility.replaceAll(total, TOTAL_TEXT, LongTimeFormatter.getInstance().format(down));
////                    template.addValue(template.getElement(TOTAL).toString(), total.toString());
////                } catch (Exception e) {
////                    template.addValue(template.getElement(TOTAL).toString(), "");
////                }
//            } else {
////                template.addValue(LIST_DATA, "-- " + Dictionary.getValue(this, "Please select parameter") + " --");
//                template.addValue(LIST_DATA, "");
////                template.addValue(template.getElement(TOTAL).toString(), "");
//            }
//            Utility.replaceAll(content, Template.CONTENT_CONTENT, template.process().toString());
//            updateContent(content, getMenu(), true);
//            return content;
//        }
//////    }
}
//            DateFormatter dateFormatter = DateFormatter.getInstanceDate(this);
//
//            Utility.replaceAll(content, Template.CONTENT_CONTENT, template.process().toString());
//            updateContent(content, getMenu());
//            return content;
//        }
//    }
//}
